list_a = list('abcdefg')
print(list_a)
print(list_a[0])
print(list_a[-1])

print(list_a[1:3])
print(list_a[-3:-1])
print(list_a[0:5:2])

l = ['python', 'java', 'javascript']
b = [1364, 1545, 1235]
info = l + b
print(l)
print(b)
print(info)

lista = ['python', 'java', 'javascript']
print(lista)
lista.append('c++')
print(lista)
lista.append(['java', 'c'])
print(lista)

print('---------------------------------------')

listb = ['python', 'java', 'javascript']
print(listb)
listb.extend('c')
print(listb)
listb.extend(['java', 'c'])
print(listb)
listb.extend(('JavaScript', 'C#', 'Go'))
print(listb)

print('---------------------------------------')

listc = ['python', 'java', 'javascript']
print(listc)
listc.insert(1, 'c++')
print(listc)
listc.insert(2, ['java', 'c'])
print(listc)
listc.insert(3, ('C#', 'Go'))
print(listc)

print('---------------------------------------')

listd = ['Python', 'C++', 'Java']
print(listd * 2)

print('---------------------------------------')

# 删除del
lang = ["Python", "C++", "Java", "PHP", "Ruby", "MATLAB"]
print(lang)
del lang[2]
print(lang)

del lang[2:4]
print(lang)

print('---------------------------------------')

# 删除pop
lang1 = ["Python", "C++", "Java", "PHP", "Ruby", "MATLAB"]
pop = lang1.pop(1)
print(pop)
print(lang1)
lang__pop = lang1.pop()
print(lang__pop)
print(lang1)

print('---------------------------------------')

nums = [40, 36, 89, 2, 36, 100, 7]
print(nums)
nums.remove(36)
print(nums)
nums.remove(36)
print(nums)
# nums.remove(36)
# print(nums) # list.remove(x): x not in list

# 清空
nums.clear()
print(nums)

# 修改
nums = [40, 36, 89, 2, 36, 100, 7]
nums[1] = 88
print(nums)

nums[2:2] = [22, 33, 44, 55, 66]
print(nums)

print('---------------------------------------')

# 查找
nums = [40, 36, 89, 2, 36, 100, 7, -20.5, -999]
index = nums.index(36)
print(index)

nums_index = nums.index(36, 2, 5)
print(nums_index)

print(nums.count(36))

print('---------------------------------------')
# for循环
my_list = [1, 2, 3, 4]
for item in my_list:
    print(item)

my_list1 = ['小明', '小华', '小天', '小娜', '小美', '小李']
print(enumerate(my_list1))
for index, element in enumerate(my_list1):
    print(index, element)

print('---------------------------------------')

# 排序
x = [1, 5, 2, 3, 4]
sorted1 = sorted(x)
print(sorted1)
sorted2 = sorted(x, reverse=True)
print(sorted2)

x1 = [3, 2, 1, 5, 4]
x1.sort()
print(x1)
x1.sort(reverse=True)
print(x1)

# 反序
x2 = [1,2,3,4]
print(x2)
x2.reverse()
print(x2)




